<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>

</head>

<body>
  <div id="app">
    ==
    <span>{{msg}}==={{num}}</span>
    聚焦： <input type="text">
    <hr />
    <button @click="num++">按钮</button>
    <ul>
      <li v-for="(item, index) in list" :key="index">{{item}}</li>
    </ul>
  </div>
  <script src="https://cdn.bootcdn.net/ajax/libs/axios/1.3.6/axios.js"></script>
  <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.7.14/vue.min.js"></script>
  <script>
    var vm = new Vue({
      el: "#app",
      data: {
        msg: 'hello  vue',
        num: 1,
        list: []
      },
      /* 创建 created=》挂载 mounted =》更新 updated=》销毁  */
      /* 数据创建之前 */
      beforeCreate () {

        console.log(this.msg, '===beforeCreate');
      },
      /* 创建好数据了 */
      created () {

        console.log(this.msg, '===created');
        axios('http://hmajax.itheima.net/api/province').then(res => {
          console.log(res, 99988);
          this.list = res.data.list
        })
      },
      /* 渲染完成之前 数据不会解析*/
      beforeMount () {
        var dom = document.querySelector('span')
        console.log(dom, '===beforeMount');
      },
      /* 渲染完成之后 数据解析完成了===操作dom元素应该在mounted */
      mounted () {
        // 全部加载完毕
        var dom2 = document.querySelector('input')
        console.log(dom2, 7777);
        dom2.focus()
        var dom = document.querySelector('span')
        console.log(dom, '===mounted');
      },
      /* 数据更新前 */
      beforeUpdate () {
        console.log('===beforeUpdate');
      },
      /* 数据更新后 */
      updated () {
        console.log('===updated');
      }
    })

    // console.log(vm, 2222);
  </script>
</body>

</html>